<template>
  <div class="homepage-hero-module">
    <!-- <div class="positionWarp">
      <p class="subtitle">一站式招商解决方案定制服务商</p>
      <div class="slogan-subtitle">创新求变   重塑增效</div>
    </div> -->
    <div class="video-container">
      <div :style="fixStyle" class="filter"></div>
      <video
        :style="fixStyle"
        muted
        autoplay
        loop
        class="fillWidth"
        v-on:canplay="canplay"
      >
        <source
          src="//syg-photo.oss-cn-shanghai.aliyuncs.com/zhaopin/video/全景延时7mb.mp4-1618568025000"
          type="video/mp4"
        />
        浏览器不支持 video 标签，建议升级浏览器。
      </video>
      <div class="poster hidden" v-if="!vedioCanPlay">
        <img :style="fixStyle" src="PATH_TO_JPEG" alt="" />
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "login",
  data() {
    return {
      vedioCanPlay: false,
      fixStyle: ""
    };
  },
  methods: {
    canplay() {
      this.vedioCanPlay = true;
    }
  },
  mounted: function() {
    window.onresize = () => {
      const windowWidth = document.body.clientWidth;
      const windowHeight = document.body.clientHeight;
      const windowAspectRatio = windowHeight / windowWidth;
      let videoWidth;
      let videoHeight;
      if (windowAspectRatio < 0.5625) {
        videoWidth = windowWidth;
        videoHeight = videoWidth * 0.5625;
        this.fixStyle = {
          height: windowWidth * 0.5625 + "px",
          width: windowWidth + "px",
          "margin-bottom": (windowHeight - videoHeight) / 2 + "px",
          "margin-left": "initial"
        };
      } else {
        videoHeight = windowHeight;
        videoWidth = videoHeight / 0.5625;
        this.fixStyle = {
          height: windowHeight + "px",
          width: windowHeight / 0.5625 + "px",
          "margin-left": (windowWidth - videoWidth) / 2 + "px",
          "margin-bottom": "initial"
        };
      }
    };
    window.onresize();
  }
};
</script>
<style lang="scss" scoped>
.positionWarp {
  position: absolute;
  z-index: 9;
  top: 50%;
  left: 50%;
  min-width: 770px;
  margin-left: -365px;
  margin-top: -72px;
  text-align: center;
  .subtitle {
    font-size: 54px;
    line-height: 61px;
    color: #fff;
    margin-bottom: 67px;
    letter-spacing: 1px;
    font-weight: 800;
  }
  .slogan-subtitle {
    color: #fff;
    letter-spacing: 23px;
    text-indent: 23px;
    font-size: 14px;
    line-height: 17px;
    opacity: 0.8;
    margin-top: 14px;
    position: relative;
  }
  .slogan-subtitle:before, .slogan-subtitle:after {
    content: "";
    display: block;
    width: 74px;
    height: 2px;
    position: absolute;
    top: calc(50% - 1px);
    background-image: linear-gradient(
      270deg,
      hsla(0, 0%, 100%, 0),
      #fff 47%,
      hsla(0, 0%, 100%, 0)
    );
  }
  .slogan-subtitle:before{
    left: 0;
  }
  .slogan-subtitle:after{
    right: 0;
  }

}
.homepage-hero-module,
.video-container {
  position: relative;
  height: 100vh;
  overflow: hidden;
}
.video-container .poster img,
.video-container video {
  z-index: 0;
  position: absolute;
  top: 0;
  left: 0;
}

.video-container .filter {
  z-index: 1;
  position: absolute;
  background: rgba(0, 0, 0, 0.2);
}
</style>
